package practice.practice6;

interface  ComputerWeight{
    public double computerWeight();
}

class Television implements ComputerWeight{
    @Override
    public double computerWeight() {
        return 30.3;
    }
}

class Computer implements ComputerWeight{
    @Override
    public double computerWeight() {
        return 25.3;
    }
}

class WashMchine implements ComputerWeight{
    @Override
    public double computerWeight() {
        return 55.0;
    }
}

class Truck{
    ComputerWeight goods[];
    double totalWeights=0;

    public Truck(ComputerWeight goods[]){
        this.goods=goods;
    }

    public void setGoods(ComputerWeight goods[]){
        this.goods=goods;
    }
    public double getTotalWeights(){
        totalWeights=0;
        for(ComputerWeight good:goods){
            totalWeights+=good.computerWeight();
        }

        return totalWeights;
    }
}

public class CheckCarWeight {
    public static void main(String[] args) {
        ComputerWeight goods[]=new ComputerWeight[650];
        for(int i=0;i<goods.length;i++){
            if(i%3==0)
                goods[i]=new Television();
            else if(i%3==1)
                goods[i]=new Computer();
            else
                goods[i]=new WashMchine();
        }

        Truck truck=new Truck(goods);
        System.out.println(truck.getTotalWeights());

        for(int i=0;i<goods.length;i++){
            if(i%2==0)
                goods[i]=new Television();
            else
                goods[i]=new Computer();

        }
        truck.setGoods(goods);
        System.out.println(truck.getTotalWeights());
    }
}
